package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 盘点记录
 * </p>
 *
 * @author linan
 * @date 2022-09-22
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ServiceInventoryCheckCheckStateEnum", description = "盘点状态 #{UN_START:待开始;UN_FINISH:未完成;FINISH:已完成-枚举")
public enum ServiceInventoryCheckCheckStateEnum implements BaseEnum {

    /**
     * UN_START="待开始"
     */
    UN_START("待开始"),
    /**
     * UN_FINISH="未完成"
     */
    UN_FINISH("未完成"),
    /**
     * FINISH="已完成"
     */
    FINISH("已完成"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ServiceInventoryCheckCheckStateEnum match(String val, ServiceInventoryCheckCheckStateEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ServiceInventoryCheckCheckStateEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ServiceInventoryCheckCheckStateEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "UN_START,UN_FINISH,FINISH", example = "UN_START")
    public String getCode() {
        return this.name();
    }

}
